var datas2;
window.onload=function(){
    var loc = location.href;
    var n1 = loc.length;//地址的总长度
    var n2 = loc.indexOf("=");//取得=号的位置
    var id = decodeURI(loc.substr(n2+1, n1-n2));//从=号后面的内容
    
  
    // console.log(id);
     
    getid();
    function getid(){
        $.ajax({
            url: 'http://api.pingcc.cn/cartoonChapter/search/'+id,
            dataType: "json",
            type: "get",
            success: function (data) {
                datas2 = data;
                for (var i = 0; i < data.data.data.length; i++) {
                  //  srcs = data.data.data[i].title;
               // console.log(data.data.data[i]);
                // <li class="box1">
                // <a href="javascript:;">武侠格斗</a>
                // </li>

                var li = document.createElement("li");

                li.innerHTML = "<a href='javascript:;' onclick='ds2()'>"+data.data.data[i].title+"</a>";
                li.className="box1";
                var ullist = document.getElementsByClassName("box")[0];

                ullist.appendChild(li);

                
                }
            },
            error: function (e) {
                console.log(e);
            }
        });

    };

};
function ds2(){

    var btna = document.getElementsByClassName("box1");
    
    
    for(var i=0;i<btna.length;i++){
      (function (i) {
          btna[i].onclick=function () {
  
         var data2=datas2.data.data[i].chapterId;
      //   console.log("aaa"+data2.cartoonId);
       //   console.log(data2);
      
    // var data3=data2.cartoonId;
      location.href="mh2.html?"+"txt="+data2;
       
    
     }
  })(i)
    }
  
  }


  
  